package com.xw.bo.ks.controller;

import com.xw.bo.ks.entity.base.BoPage;
import org.springframework.web.bind.annotation.*;
import com.xw.bo.ks.entity.KsActivityInfo;
import com.xw.bo.ks.service.KsActivityInfoService;
import com.xw.bo.ks.entity.bean.KsActivityInfoReq;

import javax.annotation.Resource;

/**
 * @author： xw ftl auto
 * @create： 2024-06-20 15:45:31
 */
@RestController
@RequestMapping("/ksActivityInfo")
public class KsActivityInfoController {

    @Resource
    private KsActivityInfoService ksActivityInfoService;

    /**
     * 简单的分页查询
     */
    @GetMapping("/page/{pageNumber}/{pageSize}")
    public BoPage<KsActivityInfo> pageKsActivityInfoList(@PathVariable Integer pageNumber,@PathVariable Integer pageSize) {
        return ksActivityInfoService.pageSampleKsActivityInfo(pageNumber,pageSize);
    }

    /**
     * 按条件分页查询
     */
    @PostMapping("/pageReq")
    public BoPage<KsActivityInfo> pageReq(@RequestBody KsActivityInfoReq ksActivityInfoReq) {
        return ksActivityInfoService.pageKsActivityInfoMapper(ksActivityInfoReq);
    }

    /**
     * 通过id查询详情
     */
    @GetMapping("/{id}")
    public KsActivityInfo getKsActivityInfoById(@PathVariable Long id) {
        return ksActivityInfoService.getById(id);
    }

    /**
     * 新增
     */
    @PostMapping
    public boolean createKsActivityInfo(@RequestBody KsActivityInfo ksActivityInfo) {
        return ksActivityInfoService.save(ksActivityInfo);
    }

    /**
     * 通过id修改
     */
    @PostMapping("/put/{id}")
    public boolean updateKsActivityInfo(@PathVariable Integer id, @RequestBody KsActivityInfo ksActivityInfo) {
        ksActivityInfo.setId(id);
        return ksActivityInfoService.updateById(ksActivityInfo);
    }

    /**
     * 删除
     */
    @GetMapping("/delete/{id}")
    public void deleteKsActivityInfo(@PathVariable Long id) {
        ksActivityInfoService.removeById(id);
    }

}
